package main

import (
	"sync/atomic"
	"time"
)

// 原子自增
func increment(addr *int32) int32 {
	for {
		old := atomic.LoadInt32(addr)
		for atomic.CompareAndSwapInt32(addr, old, old+1) {
			return old + 1
		}
	}
}

// 格式化时间戳
func formatTimestamp(t time.Time) string {
	return t.Format("2006-01-02 15:04:05")
}

// 计算连续字母数
func numberOfContinuousAlphas(str string) int {
	curr := 1
	count := 0

	for i := 0; i < len(str)-1; i++ {
		if str[i] == str[i+1] {
			curr++
		} else {
			if curr > count && curr >= 2 {
				count = curr
			}
			curr = 1
		}
	}
	return count
}
